<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>将格式化字符串写入流</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.vfprintf" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">vfprintf</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">vfprintf</span> &mdash; <span class="dc-title">将格式化字符串写入流</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.vfprintf-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>vfprintf</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$handle</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$format</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$args</code></span>
   ) : <span class="type">int</span></div>

  <p class="para rdfs-comment">
   向由 <code class="parameter">handle</code> 指定的流资源句柄中写入根据 <code class="parameter">format</code> 格式化后的字符串。
  </p>
  <p class="para">
   作用与 <span class="function"><a href="fprintf.html" class="function">fprintf()</a></span> 函数类似，但是接收一个数组参数，而不是一系列可变数量的参数。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.vfprintf-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">handle</code></dt>

     <dd>

      <p class="para">
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">format</code></dt>

     <dd>

      <p class="para">
       关于 <code class="parameter">format</code> 的描述，参见 <span class="function"><a href="sprintf.html" class="function">sprintf()</a></span>。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">args</code></dt>

     <dd>

      <p class="para">
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.vfprintf-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回输出字符串的长度。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.vfprintf-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-6005">
    <p><strong>Example #1 <span class="function"><strong>vfprintf()</strong></span>: 前导 0 的整数</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if&nbsp;(!(</span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'date.txt'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'w'</span><span style="color: #007700">)))<br />&nbsp;&nbsp;&nbsp;&nbsp;return;<br /><br /></span><span style="color: #0000BB">vfprintf</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"%04d-%02d-%02d"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #0000BB">$year</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$month</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$day</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">//&nbsp;将向&nbsp;date.txt&nbsp;写入格式化的&nbsp;ISO&nbsp;标准日期<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.vfprintf-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="printf.html" class="function" rel="rdfs-seeAlso">printf()</a> - 输出格式化字符串</span></li>
    <li class="member"><span class="function"><a href="sprintf.html" class="function" rel="rdfs-seeAlso">sprintf()</a> - Return a formatted string</span></li>
    <li class="member"><span class="function"><a href="sscanf.html" class="function" rel="rdfs-seeAlso">sscanf()</a> - 根据指定格式解析输入的字符</span></li>
    <li class="member"><span class="function"><a href="fscanf.html" class="function" rel="rdfs-seeAlso">fscanf()</a> - 从文件中格式化输入</span></li>
    <li class="member"><span class="function"><a href="vsprintf.html" class="function" rel="rdfs-seeAlso">vsprintf()</a> - 返回格式化字符串</span></li>
    <li class="member"><span class="function"><a href="number_format.html" class="function" rel="rdfs-seeAlso">number_format()</a> - 以千位分隔符方式格式化一个数字</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>